<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" style="height: 100%">
<body class="body_hei edit">
<div th:replace="include/head.html::html"></div>
<div class="layui-form" lay-filter="layuiadmin-form-useradmin" id="layuiadmin-form-useradmin"
     style="padding: 20px 0 0 0;background-color: #FFFFFF;height: 100%">
    <input type="hidden" name="oid" th:field="${bean.oid}"/>
    <div class="layui-form-item">
        <label class="layui-form-label">标题:</label>
        <div class="layui-input-block">
            <input type="text" name="title" lay-verify="required" placeholder="请输入标题" autocomplete="off"
                   class="layui-input" th:field="${bean.title}">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">图片</label>
        <div class="layui-input-inline" style="margin:0" id="editimg">
            <img src="work/img/img_loading.gif" th:src="${bean.imgUrl}" id="srcimgurl" class="layui-upload-img">
            <input type="hidden" name="head" lay-verify="required" th:field="${bean.imgUrl}" id="inputimgurl"/>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">内容</label>
        <div class="layui-input-block">
            <textarea id="demo" style="display: none;" th:text="${bean.content}"></textarea>
        </div>
    </div>
    <div class="layui-form-item layui-hide">
        <input type="button" lay-submit lay-filter="submit" id="submit" value="确认">
    </div>
</div>
<script>
    layui.use(['jquery', 'form', 'croppers','layedit'], function () {
        var croppers = layui.croppers;
        var layedit = layui.layedit;
        var $ = layui.$;
        //创建一个头像上传组件
        croppers.render({
            elem: '#editimg'
            , saveW: 150     //保存宽度
            , saveH: 150
            , mark: 1 / 1    //选取比例
            , area: ['100%','100%']  //弹窗宽度
            , textTip: "图片尺寸的尺寸限定200*200px,大小在50kb以内"
            , url: "common/uploadFile"  //图片上传接口返回和（layui 的upload 模块）返回的JOSN一样
            , done: function (url) { //上传完毕回调
                $("#inputimgurl").val(url);
                $("#srcimgurl").attr('src', url);
            }
        });
        var id = layedit_initialize(layedit,'demo')
    });
</script>
</body>
</html>